package com.zjq.smartdevice.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.zjq.smartdevice.exception.MyErrorCode;

/**
 * @User zhangjiaqi
 * @Project project
 * @Package com.zjq.smartdevice.dto
 * @Date 2022/3/17 10:30
 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class R {

    private int code;
    private String msg;
    private Object data;


    public static R setOK() {
        return setOK(null);
    }

    public static R setOK(Object data) {
        return getR(MyErrorCode.SUCCESS, "成功", data);
    }

    public static R setError() {
        return setError(null);
    }

    public static R setError(Object data) {
        return getR(MyErrorCode.FAIL, "失败", data);
    }


    public static R getR(int code,String msg,Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }



    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}

